// pages/xuanzewuliu/xuanzewuliu.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    wuliuList: [
      { name: '邮政快递包裹', flags: false, code:'YZPY' },
      { name: 'EMS', flags: false, code: 'EMS' },
      { name: '天天快递', flags: false, code: 'HHTT' },
      { name: '京东快递', flags: false, code: 'JD' },
      { name: '优速快递', flags: false, code: 'UC' },
      { name: '德邦快递', flags: false, code: 'DBL' },
      { name: '宅急送', flags: false, code: 'ZJS' },
      { name: 'TNT快递', flags: false, code: 'TNT' },
      { name: 'UPS', flags: false, code: 'UPS' },
      { name: 'DHL', flags: false, code: 'DHL' },
      { name: 'FEDEX联邦(国内件）', flags: false, code: 'FEDEX' },
      { name: 'FEDEX联邦(国际件）', flags: false, code: 'FEDEX_GJ' }
    ],
    wuliuName: '厂家自配送',
    info: { name: '厂家自配送', code: '0' },
    changjiaflag: true,
  },
  // 选择厂家自配送
  choosechangjia() {
    let wuliuList = this.data.wuliuList
    for (let i = 0; i < wuliuList.length; i++) {
      wuliuList[i].flags = false
    }
    this.setData({
      wuliuList: wuliuList,
      wuliuName: '厂家自配送',
      changjiaflag: true,
      info:{name:'厂家自配送',code:'0'}
    })
  },
  // 选择其他物流
  chooseW(e) {
    console.log(e.currentTarget.dataset.index)
    let wuliuList = this.data.wuliuList
    for (let i = 0; i < wuliuList.length; i++) {
      wuliuList[i].flags = false
    }
    wuliuList[e.currentTarget.dataset.index].flags = true
    this.setData({
      wuliuList: wuliuList,
      wuliuName: wuliuList[e.currentTarget.dataset.index].name,
      changjiaflag: false,
      info: wuliuList[e.currentTarget.dataset.index]
    })
  },
  // 点击确定
  queDing() {
    let that = this
    var pages = getCurrentPages();             //  获取页面栈
    var currPage = pages[pages.length - 1];    // 当前页面
    var prevPage = pages[pages.length - 2];    // 上一个页面
    prevPage.setData({
      wuliuInfo: that.data.info
    })
    wx.navigateBack({
      delta: 1
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})